home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / gnu / gnulib / dkbtrace / pbmplus / source / libtiff / tiffcomp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-29  |  5.4 KB  |  202 lines

  1. /* $Header: /usr/people/sam/tiff/libtiff/RCS/tiffcompat.h,v 1.15 91/07/26 10:13:05 sam Exp $ */
  2.  
  3. /*
  4.  * Copyright (c) 1990, 1991 Sam Leffler
  5.  * Copyright (c) 1991 Silicon Graphics, Inc.
  6.  *
  7.  * Permission to use, copy, modify, distribute, and sell this software and 
  8.  * its documentation for any purpose is hereby granted without fee, provided
  9.  * that (i) the above copyright notices and this permission notice appear in
  10.  * all copies of the software and related documentation, and (ii) the names of
  11.  * Sam Leffler and Silicon Graphics may not be used in any advertising or
  12.  * publicity relating to the software without the specific, prior written
  13.  * permission of Sam Leffler and Silicon Graphics.
  14.  * 
  15.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  16.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  17.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  18.  * 
  19.  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  20.  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  21.  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  22.  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
  23.  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
  24.  * OF THIS SOFTWARE.
  25.  */
  26.  
  27. #ifndef _COMPAT_
  28. #define    _COMPAT_
  29. /*
  30.  * This file contains a hodgepodge of definitions and
  31.  * declarations that are needed to provide compatibility
  32.  * between the native system and the base UNIX implementation
  33.  * that the library assumes (~4BSD).  In particular, you
  34.  * can override the standard i/o interface (read/write/lseek)
  35.  * by redefining the ReadOK/WriteOK/SeekOK macros to your
  36.  * liking.
  37.  *
  38.  * NB: This file is a mess.
  39.  */
  40. #if (defined(__STDC__) || defined(__EXTENDED__)) && !defined(USE_PROTOTYPES)
  41. #define    USE_PROTOTYPES    1
  42. #endif
  43.  
  44. #ifdef THINK_C
  45. #include <unix.h>
  46. #endif
  47. #if USE_PROTOTYPES
  48. #include <stdio.h>
  49. #endif
  50. #include <sys/types.h>
  51. #include <fcntl.h>
  52. #if defined(THINK_C) || defined(applec)
  53. #include <stdlib.h>
  54. #endif
  55.  
  56. /*
  57.  * Workarounds for BSD lseek definitions.
  58.  */
  59. #ifdef SYSV
  60. #include <unistd.h>
  61. #define    L_SET    SEEK_SET
  62. #define    L_INCR    SEEK_CUR
  63. #define    L_XTND    SEEK_END
  64. #endif
  65. #ifndef L_SET
  66. #define L_SET    0
  67. #define L_INCR    1
  68. #define L_XTND    2
  69. #endif
  70.  
  71. /*
  72.  * SVID workarounds for BSD bit
  73.  * string manipulation routines.
  74.  */
  75. #if defined(SYSV) || defined(THINK_C) || defined(applec) || defined(MSDOS)
  76. #define    bzero(dst,len)        memset(dst, 0, len)
  77. #define    bcopy(src,dst,len)    memcpy(dst, src, len)
  78. #define    bcmp(src, dst, len)    memcmp(dst, src, len)
  79. #endif
  80.  
  81. /*
  82.  * The BSD typedefs are used throughout the library.
  83.  * If your system doesn't have them in <sys/types.h>,
  84.  * then define BSDTYPES in your Makefile.
  85.  */
  86. #ifdef BSDTYPES
  87. typedef    unsigned char u_char;
  88. typedef    unsigned short u_short;
  89. typedef    unsigned int u_int;
  90. typedef    unsigned long u_long;
  91. #endif
  92.  
  93. /*
  94.  * Return an open file descriptor or -1.
  95.  */
  96. #if defined(applec) || defined(THINK_C)
  97. #define    TIFFOpenFile(name, mode, prot)    open(name, mode)
  98. #else
  99. #if defined(MSDOS)
  100. #define    TIFFOpenFile(name, mode, prot)    open(name, mode|O_BINARY, prot)
  101. #else
  102. #define    TIFFOpenFile(name, mode, prot)    open(name, mode, prot)
  103. #endif
  104. #endif
  105.  
  106. /*
  107.  * Return the size in bytes of the file
  108.  * associated with the supplied file descriptor.
  109.  */
  110. #if USE_PROTOTYPES
  111. extern    long TIFFGetFileSize(int fd);
  112. #else
  113. extern    long TIFFGetFileSize();
  114. #endif
  115.  
  116. #ifdef MMAP_SUPPORT
  117. /*
  118.  * Mapped file support.
  119.  *
  120.  * TIFFMapFileContents must map the entire file into
  121.  *     memory and return the address of the mapped
  122.  *     region and the size of the mapped region.
  123.  * TIFFUnmapFileContents does the inverse operation.
  124.  */
  125. #if USE_PROTOTYPES
  126. extern    int TIFFMapFileContents(int fd, char **paddr, long *psize);
  127. extern    void TIFFUnmapFileContents(char *addr, long size);
  128. #else
  129. extern    int TIFFMapFileContents();
  130. extern    void TIFFUnmapFileContents();
  131. #endif
  132. #endif
  133.  
  134. /*
  135.  * Mac workaround to handle the file
  136.  * extension semantics of lseek.
  137.  */
  138. #ifdef applec
  139. #define    lseek    mpw_lseek
  140. extern long mpw_lseek(int, long, int);
  141. #else
  142. extern    long lseek();
  143. #endif
  144.  
  145. /*
  146.  * Default Read/Seek/Write definitions.
  147.  */
  148. #ifndef ReadOK
  149. #define    ReadOK(fd, buf, size)    (read(fd, (char *)buf, size) == size)
  150. #endif
  151. #ifndef SeekOK
  152. #define    SeekOK(fd, off)    (lseek(fd, (long)off, L_SET) == (long)off)
  153. #endif
  154. #ifndef WriteOK
  155. #define    WriteOK(fd, buf, size)    (write(fd, (char *)buf, size) == size)
  156. #endif
  157.  
  158. #if defined(__MACH__)
  159. extern    void *malloc(size_t size);
  160. extern    void *realloc(void *ptr, size_t size);
  161. #else /* !__MACH__ */
  162. #if defined(MSDOS)
  163. #include <malloc.h>
  164. #else /* !MSDOS */
  165. #if defined(_IBMR2)
  166. extern    void *realloc();
  167. #else /* !_IBMR2 */
  168. extern    char *malloc();
  169. extern    char *realloc();
  170. #endif /* _IBMR2 */
  171. #endif /* !MSDOS */
  172. #endif /* !__MACH__ */
  173.  
  174. /*
  175.  * dblparam_t is the type that a double precision
  176.  * floating point value will have on the parameter
  177.  * stack (when coerced by the compiler).
  178.  */
  179. #ifdef applec
  180. typedef extended dblparam_t;
  181. #else
  182. typedef double dblparam_t;
  183. #endif
  184.  
  185. /*
  186.  * Varargs parameter list handling...YECH!!!!
  187.  */
  188. #if defined(__STDC__) && !defined(USE_VARARGS)
  189. #define    USE_VARARGS    0
  190. #endif
  191.  
  192. #if defined(USE_VARARGS)
  193. #if USE_VARARGS
  194. #include <varargs.h>
  195. #define    VA_START(ap, parmN)    va_start(ap)
  196. #else
  197. #include <stdarg.h>
  198. #define    VA_START(ap, parmN)    va_start(ap, parmN)
  199. #endif
  200. #endif /* defined(USE_VARARGS) */
  201. #endif /* _COMPAT_ */
  202.